package org.surfnet.oaaas.it;

import com.sun.jersey.api.client.Client;
import org.apache.commons.codec.binary.Base64;

public abstract class AbstractAuthorizationServerTest {
	protected static final String ACCESS_TOKEN = "f44a2053-cb03-46bd-80ab-190289d8f5b9";

	protected int defaultServletPort = 8080;
	protected Client client = new Client();

	protected String baseUrl() {
		return String.format("http://localhost:%s/apis-oauth2-server", System.getProperty("servlet.port", 
				String.valueOf(defaultServletPort)));
	}

	protected String baseUrlWith(String suffix) {
		return baseUrl().concat(suffix);
	}

	public static String authorizationBasic(String username, String password) {
		String concatted = username + ":" + password;
		return "Basic " + new String(Base64.encodeBase64(concatted.getBytes()));
	}

	public static String authorizationBearer(String token) {
		return "bearer " + token;
	}
}
